package com.ruoyi.serve.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.serve.domain.dto.SkuInspirationDto;
import com.ruoyi.serve.domain.dto.VerInspirationDto;
import com.ruoyi.serve.mapper.VerInspirationMapper;
import com.ruoyi.serve.service.IVerInspirationService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/serve/inspiration")
@Tag(name = "VerInspirationController", description = "verInspiration")
public class VerInspirationController extends BaseController {
    @Autowired
    private IVerInspirationService verInspirationService;
    @Autowired
    private VerInspirationMapper verInspirationMapper;

    /**
     * 获取所有灵感表记录
     */
    @PostMapping("/list")
    public TableDataInfo list(VerInspirationDto verInspirationDto) {
        startPage(1, 20);
        List<VerInspirationDto> list = verInspirationService.pageList(verInspirationDto);
        return getDataTable(list);
    }

    /**
     * 获取灵感对应的商品
     */
    @PostMapping("/getInspirationGoods")
    public AjaxResult getInspirationGoods(@RequestParam Long inspirationId) {
        List<SkuInspirationDto> list = verInspirationService.getInspirationGoods(inspirationId);
        return success(list);
    }
}
